package com.wink.subscribe;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import com.google.gson.Gson;
import com.wink.charity.Charity;

@XmlRootElement(name = "event")
@XmlAccessorType(XmlAccessType.FIELD)

public class Subscription {
	@XmlElement(name = "email")
	private String email;

	@XmlElement(name= "name")	
	private String name;
	
	@XmlElement(name= "amount")	
	private String amount;
	
	@XmlElement(name= "fromCommunity")	
	private String fromCommunity;
	
	@XmlElement(name= "charityCommunityID")	
	private String charityCommunityID;
	
	
	public String getEmail() {
		return email;
	}
	
	public void setEmail(String email) {
		this.email = email;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String getAmount() {
		return amount;
	}
	
	public void setAmount(String amount) {
		this.amount = amount;
	}
	
	public String getCommunity() {
		return fromCommunity;
	}
	
	public void setCommunity(String community) {
		fromCommunity = community;
	}
	
	public String getCommunityID() {
		return charityCommunityID;
	}
	
	public void setCommunityID(String communityID) {
		charityCommunityID = communityID;
	}
	
	public String toString() {
		StringBuffer sf = new StringBuffer();
		
		sf.append("<name> " + name);
		sf.append("<email> " + email);
		sf.append("<amount> " + amount);
		sf.append("<charityCommunityID> " + charityCommunityID);
		sf.append("<community> " + fromCommunity);
				
		return sf.toString();
	}
	
	public static String toJson(Subscription sub) {
		Gson gson = new Gson();
		String json = gson.toJson(sub, Subscription.class);
		System.out.println("---> Subscription: tojson  " + json);
		
	//	Charity retCh = gson.fromJson(json, Charity.class);
		return json;
	}
	
	public static Subscription fromJson(String json) {
		Gson gson = new Gson();
		Subscription retCh = gson.fromJson(json, Subscription.class);
		System.out.println("---> Subscription: fromJson  " + retCh.toString());
		return retCh;
	}
}